﻿namespace HRM.CORE
{

    using APP.HELPER.Data.Helper;
    using System; using Extra.ERP;
    using System.ComponentModel;
    using System.Data;
    using System.Data.SqlClient;

    public class HRM_PROCESS_RATEDETAIL
    {
        private double m_Coefficient;
        private string m_Content;
        private string m_Rate;
        private Guid m_RateDetailID;
        private Guid m_RateID;
        private double m_Score;
        private string m_SelfRate;
        private double m_SelfScore;
        private int m_Sort;

        public HRM_PROCESS_RATEDETAIL()
        {
            this.m_RateDetailID = Guid.Empty;
            this.m_RateID = Guid.Empty;
            this.m_Content = "";
            this.m_Coefficient = 1.0;
            this.m_SelfScore = 0.0;
            this.m_SelfRate = "";
            this.m_Score = 0.0;
            this.m_Rate = "";
            this.m_Sort = 0;
        }

        public HRM_PROCESS_RATEDETAIL(Guid RateDetailID, Guid RateID, string Content, double Coefficient, double SelfScore, string SelfRate, double Score, string Rate, int Sort)
        {
            this.m_RateDetailID = RateDetailID;
            this.m_RateID = RateID;
            this.m_Content = Content;
            this.m_Coefficient = Coefficient;
            this.m_SelfScore = SelfScore;
            this.m_SelfRate = SelfRate;
            this.m_Score = Score;
            this.m_Rate = Rate;
            this.m_Sort = Sort;
        }

        public DataTable CreateList(string EmployeeCode, Guid RateID)
        {
            string[] myParams = new string[] { "@EmployeeCode" };
            object[] myValues = new object[] { EmployeeCode };
            DataTable table = new SqlHelper().ExecuteDataTable("HRM_PROCESS_RATEDETAIL_CreateList", myParams, myValues);
            DataTable table2 = new DataTable();
            table2.Columns.Add("RateDetailID");
            table2.Columns.Add("RateID");
            table2.Columns.Add("Content");
            table2.Columns.Add("Coefficient", Type.GetType("System.Double"));
            table2.Columns.Add("SelfScore", Type.GetType("System.Double"));
            table2.Columns.Add("SelfRate");
            table2.Columns.Add("Score", Type.GetType("System.Double"));
            table2.Columns.Add("Rate");
            table2.Columns.Add("Sort");
            int num = 0;
            foreach (DataRow row in table.Rows)
            {
                table2.Rows.Add(new object[] { Guid.NewGuid(), RateID, row["RateName"].ToString(), double.Parse(row["Coefficient"].ToString()), 0, "D", 0, "D", ++num });
            }
            return table2;
        }

        public string DeleteAll(Guid RateID)
        {
            string[] myParams = new string[] { "@RateID" };
            object[] myValues = new object[] { RateID };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_PROCESS_RATEDETAIL_DeleteAll", myParams, myValues);
        }

        public bool Exist(Guid RateDetailID)
        {
            bool hasRows = false;
            string[] myParams = new string[] { "@RateDetailID" };
            object[] myValues = new object[] { RateDetailID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("HRM_PROCESS_RATEDETAIL_Get", myParams, myValues);
            if (reader != null)
            {
                hasRows = reader.HasRows;
                reader.Close();
                helper.Close();
                reader = null;
            }
            return hasRows;
        }

        public string Get(Guid RateDetailID)
        {
            string str = "";
            string[] myParams = new string[] { "@RateDetailID" };
            object[] myValues = new object[] { RateDetailID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("HRM_PROCESS_RATEDETAIL_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_RateDetailID = reader.GetGuid(reader.GetOrdinal("RateDetailID"));
                    this.m_RateID = reader.GetGuid(reader.GetOrdinal("RateID"));
                    this.m_Content = Convert.ToString(reader["Content"]);
                    this.m_Coefficient = Convert.ToDouble(reader["Coefficient"]);
                    this.m_SelfScore = Convert.ToDouble(reader["SelfScore"]);
                    this.m_SelfRate = Convert.ToString(reader["SelfRate"]);
                    this.m_Score = Convert.ToDouble(reader["Score"]);
                    this.m_Rate = Convert.ToString(reader["Rate"]);
                    this.m_Sort = Convert.ToInt32(reader["Sort"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public string Get(SqlConnection myConnection, Guid RateDetailID)
        {
            string str = "";
            string[] myParams = new string[] { "@RateDetailID" };
            object[] myValues = new object[] { RateDetailID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader(myConnection, "HRM_PROCESS_RATEDETAIL_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_RateDetailID = reader.GetGuid(reader.GetOrdinal("RateDetailID"));
                    this.m_RateID = reader.GetGuid(reader.GetOrdinal("RateID"));
                    this.m_Content = Convert.ToString(reader["Content"]);
                    this.m_Coefficient = Convert.ToDouble(reader["Coefficient"]);
                    this.m_SelfScore = Convert.ToDouble(reader["SelfScore"]);
                    this.m_SelfRate = Convert.ToString(reader["SelfRate"]);
                    this.m_Score = Convert.ToDouble(reader["Score"]);
                    this.m_Rate = Convert.ToString(reader["Rate"]);
                    this.m_Sort = Convert.ToInt32(reader["Sort"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public string Get(SqlTransaction myTransaction, Guid RateDetailID)
        {
            string str = "";
            string[] myParams = new string[] { "@RateDetailID" };
            object[] myValues = new object[] { RateDetailID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader(myTransaction, "HRM_PROCESS_RATEDETAIL_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_RateDetailID = reader.GetGuid(reader.GetOrdinal("RateDetailID"));
                    this.m_RateID = reader.GetGuid(reader.GetOrdinal("RateID"));
                    this.m_Content = Convert.ToString(reader["Content"]);
                    this.m_Coefficient = Convert.ToDouble(reader["Coefficient"]);
                    this.m_SelfScore = Convert.ToDouble(reader["SelfScore"]);
                    this.m_SelfRate = Convert.ToString(reader["SelfRate"]);
                    this.m_Score = Convert.ToDouble(reader["Score"]);
                    this.m_Rate = Convert.ToString(reader["Rate"]);
                    this.m_Sort = Convert.ToInt32(reader["Sort"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public DataTable GetList(Guid RateID)
        {
            string[] myParams = new string[] { "@RateID" };
            object[] myValues = new object[] { RateID };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_PROCESS_RATEDETAIL_GetList", myParams, myValues);
        }

        public string Insert()
        {
            string[] myParams = new string[] { "@RateDetailID", "@RateID", "@Content", "@Coefficient", "@SelfScore", "@SelfRate", "@Score", "@Rate", "@Sort" };
            object[] myValues = new object[] { this.m_RateDetailID, this.m_RateID, this.m_Content, this.m_Coefficient, this.m_SelfScore, this.m_SelfRate, this.m_Score, this.m_Rate, this.m_Sort };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_PROCESS_RATEDETAIL_Insert", myParams, myValues);
        }

        public string Insert(SqlTransaction myTransaction)
        {
            string[] myParams = new string[] { "@RateDetailID", "@RateID", "@Content", "@Coefficient", "@SelfScore", "@SelfRate", "@Score", "@Rate", "@Sort" };
            object[] myValues = new object[] { this.m_RateDetailID, this.m_RateID, this.m_Content, this.m_Coefficient, this.m_SelfScore, this.m_SelfRate, this.m_Score, this.m_Rate, this.m_Sort };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_PROCESS_RATEDETAIL_Insert", myParams, myValues);
        }

        public string Insert(Guid RateDetailID, Guid RateID, string Content, double Coefficient, double SelfScore, string SelfRate, double Score, string Rate, int Sort)
        {
            string[] myParams = new string[] { "@RateDetailID", "@RateID", "@Content", "@Coefficient", "@SelfScore", "@SelfRate", "@Score", "@Rate", "@Sort" };
            object[] myValues = new object[] { RateDetailID, RateID, Content, Coefficient, SelfScore, SelfRate, Score, Rate, Sort };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_PROCESS_RATEDETAIL_Insert", myParams, myValues);
        }

        public string Insert(SqlConnection myConnection, Guid RateDetailID, Guid RateID, string Content, double Coefficient, double SelfScore, string SelfRate, double Score, string Rate, int Sort)
        {
            string[] myParams = new string[] { "@RateDetailID", "@RateID", "@Content", "@Coefficient", "@SelfScore", "@SelfRate", "@Score", "@Rate", "@Sort" };
            object[] myValues = new object[] { RateDetailID, RateID, Content, Coefficient, SelfScore, SelfRate, Score, Rate, Sort };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "HRM_PROCESS_RATEDETAIL_Insert", myParams, myValues);
        }

        public string Insert(SqlTransaction myTransaction, Guid RateDetailID, Guid RateID, string Content, double Coefficient, double SelfScore, string SelfRate, double Score, string Rate, int Sort)
        {
            string[] myParams = new string[] { "@RateDetailID", "@RateID", "@Content", "@Coefficient", "@SelfScore", "@SelfRate", "@Score", "@Rate", "@Sort" };
            object[] myValues = new object[] { RateDetailID, RateID, Content, Coefficient, SelfScore, SelfRate, Score, Rate, Sort };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_PROCESS_RATEDETAIL_Insert", myParams, myValues);
        }

        public string NewID()
        {
            return SqlHelper.GenCode("HRM_PROCESS_RATEDETAIL", "JobCode", "CV");
        }

        [DisplayName("Coefficient"), Category("Column")]
        public double Coefficient
        {
            get
            {
                return this.m_Coefficient;
            }
            set
            {
                this.m_Coefficient = value;
            }
        }

        [Category("Column"), DisplayName("Content")]
        public string Content
        {
            get
            {
                return this.m_Content;
            }
            set
            {
                this.m_Content = value;
            }
        }

        public string ProductName
        {
            get
            {
                return "Class HRM_PROCESS_RATEDETAIL";
            }
        }

        public string ProductVersion
        {
            get
            {
                return "1.0.0.0";
            }
        }

        [Category("Column"), DisplayName("Rate")]
        public string Rate
        {
            get
            {
                return this.m_Rate;
            }
            set
            {
                this.m_Rate = value;
            }
        }

        [DisplayName("RateDetailID"), Category("Primary Key")]
        public Guid RateDetailID
        {
            get
            {
                return this.m_RateDetailID;
            }
            set
            {
                this.m_RateDetailID = value;
            }
        }

        [DisplayName("RateID"), Category("Column")]
        public Guid RateID
        {
            get
            {
                return this.m_RateID;
            }
            set
            {
                this.m_RateID = value;
            }
        }

        [Category("Column"), DisplayName("Score")]
        public double Score
        {
            get
            {
                return this.m_Score;
            }
            set
            {
                this.m_Score = value;
            }
        }

        [Category("Column"), DisplayName("SelfRate")]
        public string SelfRate
        {
            get
            {
                return this.m_SelfRate;
            }
            set
            {
                this.m_SelfRate = value;
            }
        }

        [DisplayName("SelfScore"), Category("Column")]
        public double SelfScore
        {
            get
            {
                return this.m_SelfScore;
            }
            set
            {
                this.m_SelfScore = value;
            }
        }

        [Category("Column"), DisplayName("Sort")]
        public int Sort
        {
            get
            {
                return this.m_Sort;
            }
            set
            {
                this.m_Sort = value;
            }
        }
    }
}

